package routes

import (
    "github.com/beego/beego/v2/server/web"
    "volux/internal/api/handlers"
    "volux/internal/api/middleware"
)

func InitRoutes() {
    // API版本v1
    ns := web.NewNamespace("/v1",
        // 中间件
        web.NSBefore(middleware.Auth),
        
        // Bdev相关路由
        web.NSRouter("/bdevs", &handlers.BdevHandler{}, "get:GetBdevs;post:CreateBdev"),
        web.NSRouter("/bdevs/:name", &handlers.BdevHandler{}, "delete:DeleteBdev"),
        
        // Subsystem相关路由
        web.NSRouter("/subsystems", &handlers.SubsystemHandler{}, "get:GetSubsystems;post:CreateSubsystem"),
        // ... 其他路由
    )
    
    web.AddNamespace(ns)
}

func StartServer() error {
    InitRoutes()
    return web.Run()
}
